package com.mcc.app.process.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.process.domain.SinterSilo;
import com.mcc.app.process.service.ISinterSiloService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 料仓
 *
 * @author gxy
 * @date 2025-06-20
 */
@Api(tags = "料仓")
@RestController
@RequestMapping("/sinter/silo")
public class SinterSiloController extends BaseController {

    @Autowired
    private ISinterSiloService sinterSiloService;

    @ApiOperation("查询料仓列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('demo:silo:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<SinterSilo>> list(SinterSilo sinterSilo) {
        List<SinterSilo> list = sinterSiloService.selectSinterSiloList(sinterSilo);
        return getDataTable(list);
    }

    @ApiOperation("查询料仓列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('demo:silo:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<SinterSilo>> page(SinterSilo sinterSilo) {
        startPage();
        List<SinterSilo> list = sinterSiloService.selectSinterSiloList(sinterSilo);
        return getDataTable(list);
    }

    @ApiOperation("获取料仓详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('demo:silo:query')")
    @GetMapping("/get/{siloId}")
    public AjaxResult<SinterSilo> getInfo(@PathVariable("siloId") Long siloId) {
        return AjaxResult.success(sinterSiloService.selectSinterSiloById(siloId));
    }

    @ApiOperation("新增料仓")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('demo:silo:add')")
    @Log(title = "料仓", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SinterSilo sinterSilo) {
        return toAjax(sinterSiloService.insertSinterSilo(sinterSilo));
    }

    @ApiOperation("修改料仓")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('demo:silo:edit')")
    @Log(title = "料仓", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody SinterSilo sinterSilo) {
        return toAjax(sinterSiloService.updateSinterSilo(sinterSilo));
    }

    @ApiOperation("删除料仓")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('demo:silo:remove')")
    @Log(title = "料仓", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{siloIds}")
    public AjaxResult remove(@PathVariable Long[] siloIds) {
        return toAjax(sinterSiloService.deleteSinterSiloByIds(siloIds));
    }
}
